package com.xtwy.simple;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.zxing.Result;
import com.xtwy.qrcodeview.QRCodeView;

/*
 * -----------------------------------------------------------------
 * Copyright (C) 2014-2016, by your company, All rights reserved.
 * -----------------------------------------------------------------
 * 文    件: MainActivity.java
 * 作    者: 侯建军
 * 版    权: 1.0.0
 * 描    述: 二维码
 * 创建时间: 2018/9/19 11:48
 * 更新时间：2018/9/19 11:48
 * -----------------------------------------------------------------
 * 2018/9/19 11:48 : 创建 MainActivity.java (侯建军);
 * -----------------------------------------------------------------
 */
public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private QRCodeView qrCodeView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        qrCodeView = (QRCodeView) findViewById(R.id.qr_code_view);
        qrCodeView.setOnQRCodeListener(new QRCodeView.OnQRCodeRecognitionListener() {
            @Override
            public void onQRCodeRecognition(Result result) {
                Intent intent = new Intent(MainActivity.this, ShowQRCodeContentActivity.class);
                intent.putExtra("qr_content", result.getText());
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        qrCodeView.startPreview();
    }

    @Override
    protected void onPause() {
        qrCodeView.stopPreview();
        super.onPause();
    }
}

